package com.service.business.member.controller;

import com.service.business.member.controller.rep.MemberAccumulatedRep;
import com.service.business.member.controller.rep.MemberJARep;
import com.service.core.rest.BaseController;
import com.service.core.rest.request.PageRequest;
import com.service.core.rest.response.OneResponse;
import com.service.business.framework.log.RequestLog;
import com.service.business.member.service.MemberJAService;
import com.service.core.rest.response.PageResponse;
import com.service.dao.enums.CoinsEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <dl>
 * <dt>back-end</dt>
 * <dd>Description:</dd>
 * <dd>Copyright: Copyright (C) 2015</dd>
 * <dd>Company: </dd>
 * <dd>CreateDate: 2019年09月24日</dd>
 * </dl>
 *
 * @author
 */
@Slf4j
@RestController()
@RequestMapping("member-ja")
@Api(tags = "会员流水相关信息")
public class MemberJAController extends BaseController {

    @Autowired
    private MemberJAService memberJAService;


    @ApiOperation("收益总计")
    @RequestLog("收益总计")
    @PostMapping("accumulated")
    public OneResponse<MemberAccumulatedRep> totalAccumulated() {
        return successQueryOneResponse(memberJAService.getTotalAccumulated());
    }

    @ApiOperation("收益详情")
    @RequestLog("收益详情")
    @PostMapping("accumulated-detail/{coinsName}")
    public PageResponse<MemberJARep> accumulatedDetail(@PathVariable("coinsName") CoinsEnum coin, @ApiParam @RequestBody @Validated PageRequest request) {
        return successQueryPageResponse(memberJAService.pageAccumulated(coin, request));
    }

    @RequestLog("会员某账户流水")
    @ApiOperation("会员流水")
    @PostMapping("page/{coinsName}")
    public PageResponse<MemberJARep> pageMemberJA(@PathVariable("coinsName") CoinsEnum coin, @ApiParam @RequestBody @Validated PageRequest request) {
        return successQueryPageResponse(memberJAService.pageMemberJA(coin, request));
    }

    @RequestLog("会员某账户某订单流水")
    @ApiOperation("会员订单流水")
    @PostMapping("page-order/{coinsName}/{orderId}")
    public PageResponse<MemberJARep> pageMemberJA4Order(@PathVariable("coinsName") CoinsEnum coin,@PathVariable("orderId") Integer orderId, @ApiParam @RequestBody @Validated PageRequest request) {
        return successQueryPageResponse(memberJAService.pageMemberJA(coin, orderId, request));
    }
}
